package cn.itcast.Rainbow_self_mention.HandlerMessage;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import java.util.HashMap;
import java.util.Map;

import cn.itcast.Rainbow_self_mention.Activity.Login;
import cn.itcast.Rainbow_self_mention.Activity.Personal;
import cn.itcast.Rainbow_self_mention.Activity.Regist;
import cn.itcast.Rainbow_self_mention.Activity.ResetPassword;

public class CounterMessage {

    Handler Rhandler = Regist.handler;
    Handler Phandler = Personal.handler;
    Handler Lhandler = Login.handler;
    Handler Resethandler= ResetPassword.handler;

    Map<Integer,String> paramter=new HashMap<>();
    public CounterMessage(){
        paramter.put(11,"登录成功");
        paramter.put(12,"登录失败");
        paramter.put(13,"已在别处登录");
        paramter.put(21,"注册成功");
        paramter.put(22,"注册失败");
        paramter.put(23,"已存在账户");
        paramter.put(31,"退出成功");
        paramter.put(32,"退出失败");
        paramter.put(34,"网络连接成功");
        paramter.put(35,"网络连接错误");
        paramter.put(41,"修改成功");
        paramter.put(42,"修改失败");
        paramter.put(43,"用户不存在");
    }

    public void sentToReset(int num){
        Message reset = Resethandler.obtainMessage();
        Bundle bundle = new Bundle();
        bundle.putString("sentresult", paramter.get(num));
        reset.setData(bundle);
        Resethandler.sendMessage(reset);
    }

    public void sentToPersonal(int num){
        Message exist = Phandler.obtainMessage();
        Bundle bundle = new Bundle();
        bundle.putString("sentresult", paramter.get(num));
        exist.setData(bundle);
        Phandler.sendMessage(exist);
    }

    public void sentToRegistry(int num){
        Message regist = Rhandler.obtainMessage();
        Bundle bundle = new Bundle();
        bundle.putString("sentresult", paramter.get(num));
        regist.setData(bundle);
        Rhandler.sendMessage(regist);
    }

    public void sentToLogin(int num){
        Message regist = Lhandler.obtainMessage();
        Bundle bundle = new Bundle();
        bundle.putString("sentresult", paramter.get(num));
        regist.setData(bundle);
        Lhandler.sendMessage(regist);
    }
    public void Link(int num){
        Bundle bundle = new Bundle();
        Message login = Lhandler.obtainMessage();
        Message regist = Rhandler.obtainMessage();
        Message exist = Phandler.obtainMessage();
        Message reset = Resethandler.obtainMessage();
        bundle.putString("sentresult", paramter.get(num));
        login.setData(bundle);
        regist.setData(bundle);
        exist.setData(bundle);
        reset.setData(bundle);
        Lhandler.sendMessage(login);
        Rhandler.sendMessage(regist);
        Phandler.sendMessage(exist);
        Resethandler.sendMessage(reset);
    }


}
